import 'package:catguard/views/dialog_manager.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:line_awesome_flutter/line_awesome_flutter.dart';

import '../../config/config.dart';
import '../../views/common_widget.dart';
import 'logic.dart';

class MyInfoPage extends StatelessWidget {
  MyInfoPage({super.key});

  final logic = Get.find<MyInfoLogic>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Config.colorBg,
      resizeToAvoidBottomInset: false,
      body: Column(
        children: [
          CommonWidget.commonAppBar("个人信息"),

          //头像区
          GestureDetector(
            onTap: () {},
            child: Container(
              width: double.infinity,
              margin: EdgeInsets.only(top: 35.w, left: 35.w, right: 35.w),
              padding: EdgeInsets.symmetric(horizontal: 35.w, vertical: 30.w),
              decoration: BoxDecoration(
                color: Config.colorBg2,
                borderRadius: BorderRadius.circular(Config.roundBig.w),
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    '头像',
                    style:
                        TextStyle(color: Config.colorText1, fontSize: Config.textSizeSubTitle.sp),
                  ),
                  Container(
                    width: 110.w,
                    height: 110.w,
                    decoration: BoxDecoration(
                        color: Config.colorText3.withOpacity(0.2),
                        borderRadius: BorderRadius.circular(60.w)),
                    child: Icon(
                      LineAwesomeIcons.user,
                      size: 60.w,
                      color: Config.colorText3.withOpacity(0.6),
                    ),
                  ),
                ],
              ),
            ),
          ),
          //菜单
          Container(
            width: double.infinity,
            margin: EdgeInsets.only(top: 30.w, left: 35.w, right: 35.w),
            padding: EdgeInsets.symmetric(horizontal: 35.w, vertical: 4.w),
            decoration: BoxDecoration(
              color: Config.colorBg2,
              borderRadius: BorderRadius.circular(Config.roundBig.w),
            ),
            child: ListView(
              padding: const EdgeInsets.symmetric(vertical: 0),
              scrollDirection: Axis.vertical,
              shrinkWrap: true,
              children: [
                menuItem("昵称", Icons.emoji_emotions_outlined, () {
                  DialogManager.showEditDialog("修改昵称", (text){},hint: "Sam");
                }, subTitle: "Sam"),
                CommonWidget.commonDivider(),
                menuItem("性别", Icons.transgender_rounded, () {}, subTitle: "请选择"),
                CommonWidget.commonDivider(),
                menuItem("生日", Icons.cake_outlined, () {}, subTitle: "请选择"),
              ],
            ),
          ),
        ],
      ),
    );
  }

  menuItem(String title, IconData icon, Function() onTap, {String? subTitle}) {
    return InkWell(
      onTap: onTap,
      child: SizedBox(
        height: 114.w,
        child: Row(
          children: [
            Icon(
              icon,
              size: 50.w,
              color: Config.colorText1,
            ),
            SizedBox(width: 20.w),
            Text(
              title,
              style: TextStyle(color: Config.colorText1, fontSize: Config.textSizeContent.sp),
            ),
            Expanded(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Visibility(
                    visible: subTitle != null,
                    child: Text(
                      subTitle ?? "",
                      style:
                          TextStyle(color: Config.colorText3, fontSize: Config.textSizeContent.sp),
                    ),
                  ),
                  SizedBox(width: 10.w),
                  Icon(
                    Icons.arrow_forward_ios_rounded,
                    color: Config.colorText3.withOpacity(0.7),
                    size: 32.w,
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
